/*
 * @Author: your name
 * @Date: 2021-01-21 18:52:16
 * @LastEditTime: 2021-12-13 10:53:38
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vant\src\main.js
 */
import Vue from "vue";
import App from "./App.vue";
import router from "./router"
import { Toast } from 'vant';
import store from "./store";
// import vConsole from '@/assets/js/vconsole.js'//调试器

import Meta from "vue-meta";
Vue.use(Meta);
// 初始化样式
import "@/assets/css/reset.css";

// rem 适配js
// import 'amfe-flexible'

// 设置html根字体大小
import "@/assets/css/font_html.css";

// 导入vant css(由于采用配置主题方式，这里需要导入vant less 主题文件,如果不需要自定义主题注释下面代码，然后解除config/cdn.js 中vant主题样式的注释)
import "vant/lib/index.less";

// 路由权限拦截
import "./router/permission";

// 初始化svg图标
import "./icons/index";

// mock模式
if (process.env.VUE_APP_MODE == "mock") {
  require("../mock");
  console.log("本地mock数据已导入");
}

Toast.setDefaultOptions({ duration: 3000 });


// 注册自定义全局组件
import components from "./utils/components";

// 注册全局插件
import plugins from "./utils/plugins";



Vue.use(plugins).use(components);

Vue.prototype.getLoginIndex=function(){

}

//生产uuid
Vue.prototype.getuuid=function(){
  function S4() {
      return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  }
  return (S4() + S4() + "-" + S4() + "-" + S4());
}
// 防抖处理-立即执行
const on = Vue.prototype.$on
Vue.prototype.$on = function (event, func) {
  let timer;
  let flag = true;
  let newFunc = func
  if (event == 'click') {
    newFunc = function () {
      if(flag) {
        func.apply(this, arguments)
        flag = false
      }
      clearTimeout(timer)
      timer = setTimeout(function () {
        flag = true
      }, 2000)//时间2秒
    }
  }
  on.call(this, event, newFunc)
}
new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
